package com.service.bean.alarm;

import java.lang.reflect.Method;

import com.service.bean.device.Vehicle;
import com.service.bean.signal.GpsSignal;

public class AlarmRule {
	/**
	 * 报警分类</br>
	 * A: 普通报警</br>
	 * B: 区域报警</br>
	 * C: 工作状态报警</br>
	 * D: 违规报警
	 */
	public String alarmType;
	/**
	 * 报警级别
	 */
	public String alarmLevel;
	/**
	 * 报警类别
	 */
	public String alarmCategory;
	/**
	 * 报警名称
	 */
	public String alarmName;
	/**
	 * 设定值1
	 */
	public String value1;
	/**
	 * 设定值2
	 */
	public String value2;
	/**
	 * 设定值3
	 */
	public String value3;
	/**
	 * 设定值4
	 */
	public String value4;
	
	@SuppressWarnings("unchecked")
	public AlarmInfo doAlarm(Vehicle vehicle,GpsSignal bean){
		AlarmInfo ai = null;
		//Method m = null;
		try {
			@SuppressWarnings("rawtypes")
			Class fileClass = Class.forName("com.service.alarm.AlarmFunction");
			Method m = fileClass.getDeclaredMethod("alarm"+this.alarmCategory,vehicle.getClass(),bean.getClass(),this.getClass());
			ai = (AlarmInfo) m.invoke(fileClass.newInstance(),vehicle,bean,this); 
			//m.invoke(fileClass.newInstance(),vehicle,bean,this); 
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ai;
	}
}